home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Classes / SocketClasses / SktSocketUser.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-23  |  6.4 KB  |  135 lines

  1. /***************************************************************************
  2. *                                                                          *
  3. * SktSocketUser.h                                                          *
  4. * Copyright 1992 by Nik A Gervae                                           *
  5. *                                                                          *
  6. * One of a set of three Objective-C classes (SktSocketManager, SktSocket,  *
  7. * and SktSocketUser) which implement a convenient interface to Berkeley    *
  8. * stream sockets under NeXTSTEP(r).  See the accompanying class            *
  9. * specifications (files with a .rtf or .spec suffix) for further           *
  10. * information.                                                             *
  11. *                                                                          *
  12. * NeXTSTEP is a registered trademark of NeXT Computer, Inc.                *
  13. *                                                                          *
  14. ****************************************************************************
  15. *                                                                          *
  16. * LICENSE                                                                  *
  17. *                                                                          *
  18. * This program is free software; you can redistribute it and/or modify     *
  19. * it under the terms of the GNU General Public License as published by     *
  20. * the Free Software Foundation.                                            *
  21. *                                                                          *
  22. * The program and this makefile are distributed in the hope that it will   *
  23. * be useful, but are provided "AS IS" AND WITHOUT ANY WARRANTY; without    *
  24. * any express or implied warranty of MERCHANTABILITY or FITNESS FOR A      *
  25. * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
  26. * Any use or distribution of the program and documentation must include    *
  27. * appropriate copyrights to acknowledge Nik A. Gervae and the Free         *
  28. * Software Foundation, Inc.                                                *
  29. *                                                                          *
  30. * You should have received a copy of the GNU General Public License        *
  31. * along with this program; if not, write to the Free Software              *
  32. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                *
  33. *                                                                          *
  34. ****************************************************************************
  35. *                                                                          *
  36. * VERSION HISTORY                                                          *
  37. *                                                                          *
  38. * Version numbers are simply dates in the form YYYYMMDD.  These represent  *
  39. * the date that version was finished.  Only significantly changed versions *
  40. * are reported here, or those versions requiring explanation of changes.   *
  41. * There may be many interim stages between dated versions.                 *
  42. *                                                                          *
  43. * DateVersion Primary Author  Notes                                        *
  44. * ----------- --------------- -------------------------------------------- *
  45. * 19920327    Nik A Gervae    First released version                       *
  46. * 19920723    Nik A Gervae    Actually released                            *
  47. *                                                                          *
  48. ***************************************************************************/
  49.  
  50. #ifdef NS3
  51. #import <objc/zone.h>
  52. #else
  53. #import <zone.h>
  54. #endif
  55.  
  56. #import <objc/Object.h>
  57.  
  58. #import "SktSocket.h"
  59. #import "util.h"
  60.  
  61. /*
  62.  * INQSIZE is the minimum size of a queue buffer.
  63.  * It should be at least twice the observed maximum
  64.  * length of a normal input line (which is usually
  65.  * less than a terminal's width, 80 chars or so).
  66.  */
  67. #define INQSIZE  512
  68.  
  69. /***************************************************************************
  70. *                                                                          *
  71. * SktSocketUser class                                                      *
  72. *                                                                          *
  73. * The instance variables socket, doesStrip, doesStripCRLF, and delimiter   *
  74. * are accessed only through methods (except in -initWithSocket: and        *
  75. * -free), so that you can override the behavior in subclasses by returning *
  76. * specific values.  You could have a subclass that always strips by        *
  77. * overriding -doesStrip to always return YES, for example.  It may sound   *
  78. * gratuitous now, but the habit *will* pay off sooner or later.            *
  79. *                                                                          *
  80. ***************************************************************************/
  81. @interface SktSocketUser : Object
  82. {
  83.   struct SktSocket *socket;  // SktSocket object handling actual I/O
  84.  
  85.   BOOL     doesStrip;        // whether to strip delimiter from input
  86.   BOOL     doesStripCRLF;    // whether to strip any CR or LF from input
  87.  
  88.   char     delimiter;        // delimiter for lines; defaults to '\n'
  89.   char    *inputQueue;       // text waiting to be processed
  90.   long int queueLength;      // # chars in queue
  91.   long int queueLimit;       // if >0, max # of lines allowed in queue
  92.  
  93.   NXZone  *zone;             // zone alloc'ed from
  94. }
  95.  
  96.  
  97. // Initializing
  98. - initWithSocket:(struct SktSocket *)aSocket;
  99. - init;
  100. - free;
  101.  
  102. - setDelimiter:(char)aChar;
  103. - (char)delimiter;
  104. - setdoesStrip:(BOOL)flag;
  105. - (BOOL)doesStrip;
  106. - setDoesStripCRLF:(BOOL)flag;
  107. - (BOOL)doesStripCRLF;
  108. - setQueueLimit:(long int)limit;
  109. - (long int)queueLimit;
  110.  
  111. // Access methods
  112.  
  113. - (struct SktSocket *)setSocket:(struct SktSocket *)aSocket;
  114. - (struct SktSocket *)socket;
  115.  
  116. // I/O processing
  117.  
  118. - queueInput:(const char *)input ofLength:(long int)length;
  119. - purgeInput;
  120.  
  121. - queueOutput:(const char *)output ofLength:(long int)length;
  122. - queueOutputString:(const char *)aString;
  123.  
  124. - (long int)queueLength;
  125. - (long int)getInput:(char *)input ofLength:(long int)length orLess:(BOOL)flag;
  126. - ungetInput:(char *)input ofLength:(long int)length;
  127. - (long int)getAllInput:(char **)input;
  128.  
  129. - (char *)inputToChar:(char)aChar;
  130. - (char *)inputToChar:(char)aChar inZone:(NXZone *)aZone;
  131.  
  132. - (char *)nextInputLine;
  133. - (char *)nextInputLineInZone:(NXZone *)aZone;
  134.  
  135. @end /*interface SktSocketUser*/